{extend name="base" /}
{block name="main"}
<div class="tpl-content-wrapper">
    <div class="tpl-content-page-title">
        节点列表
    </div>
    <ol class="am-breadcrumb">
        <li><a href="{:url('admin/Index/index')}" class="am-icon-home">首页</a></li>
        <li class="am-active">权限管理</li>
        <li class="am-active">节点列表</li>
    </ol>
    <div class="tpl-portlet-components">
        <div class="portlet-title">
            <div class="caption font-green bold">
                <span class="am-icon-code"></span> 列表
            </div>


        </div>
        <div class="tpl-block">
            <div class="am-g">
                <div class="am-u-sm-12 am-u-md-6">
                    <div class="am-btn-toolbar">
                        <div class="am-btn-group am-btn-group-xs">
                            <a href="{:url('admin/Node/create')}" type="button" class="am-btn am-btn-default am-btn-success"><span class="am-icon-plus"></span> 新增</a>
                        </div>
                    </div>
                </div>


            </div>
            <div class="am-g">
                <div class="am-u-sm-12">
                    <form class="am-form">
                        <table class="am-table am-table-striped am-table-hover table-main am-table-centered am-table-compact">
                            <thead>
                            <tr>
                                <th class="table-check"><input type="checkbox" class="tpl-table-fz-check"></th>
                                <th class="table-id">ID</th>
                                <th class="table-title">节点名</th>
                                <th class="table-type">mname</th>
                                <th class="table-type">aname</th>
                                <th class="table-date am-hide-sm-only">状态</th>
                                <th class="table-set">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            {volist name='data' id='node'}
                            <tr>
                                <td><input type="checkbox"></td>
                                <td>{$node.id}</td>
                                <td>{$node.name}</td>
                                <td>{$node.mname}</td>
                                <td>{$node.aname}</td>
                                {if $node.status==1}
                                <td class="am-hide-sm-only"><a class="u-status" u-status="{$node.status}" u-uid="{$node.id}">激活</a></td>
                                {else}
                                <td class="am-hide-sm-only"><a style="color: #93a2a9" class="u-status" u-status="{$node.status}" u-uid="{$node.id}">禁用</a></td>
                                {/if}
                                <td>
                                    <div class="">
                                        <div class="am-btn-group am-btn-group-xs">
                                            <a href="{:url('admin/Node/edit',['id'=>$node.id])}" class="am-btn am-btn-default am-btn-xs fff"><span class="am-icon-pencil-square-o"></span> 编辑节点</a>
                                            <button type="button" class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only btn-del" iddata="{$node.id}"><span class="am-icon-trash-o"></span> 删除节点</button>
                                        </div>
                                    </div>
                                </td>
                            </tr>
                            {/volist}
                            </tbody>
                        </table>
                        <div class="am-cf">

                            <div class="am-fr">
                                    {$data->render()}
                            </div>
                        </div>
                        <hr>

                    </form>
                </div>

            </div>
        </div>
        <div class="tpl-alert"></div>
    </div>


    <script>
        $(function () {
            $('.btn-del').click(function(){
                var id = $(this).attr('iddata');
                var obj = $(this).parents('tr');
//                console.log($(this).attr('iddata'))
                if(confirm('你确定要删除该节点吗')){
//                    console.log(111);
                    delajax(id,obj,'node');
                    $('.nodecount').html($('.nodecount').html()-1);
                }
            })

            var $ustu = $('.u-status');
            $ustu.click(function(){
                var uid = $(this).attr('u-uid');
                var stu = $(this).attr('u-status');
                var obj = $(this);
//           console.log(stu);
                csajax(uid,stu,obj,'/admin/Node/changestatus');

            })
        })
    </script>






</div>
{/block}